**************************************************************************
*																		*
*			Campaign Panel Book Chapter 5 - Transformation Long Format								*
*																		*
*************************************************************************

use "${data}\ZA5704_en_v3-2-0.dta", clear

keep lfdn teilnahme n_teilnahmen

cd "${path}\Reproducible Do-Files\Chapter 5\Data"

// Addition of operationalized variables
merge 1:1 lfdn using mobilization13
drop _merge

merge 1:1 lfdn using kommunikation13
drop _merge

merge 1:1 lfdn using koginvolv13
drop _merge

merge 1:1 lfdn using attitudes13 
drop _merge

*--------------------------------------
* Transform into long format
*---------------------------------------

reshape long wwbt watcheddebate wahlomatg wahlarenag_mg ///
	wahlarenag_sg gesprhin pk_gesamtino pr_bild i_nupol ///
	pr_paper pr_andz tv_oeff tv_privat m_gesamti ///
	wkampfint intefficacy extefficacy zufr ///
	indiff entfremd entfremda, i(lfdn) j(welle) 

	
*------------------------------------------------------------------
* Adjustment of all values by personal mean value	
*-------------------------------------------------------------------
		
foreach var in wwbt watcheddebate wahlomatg wahlarenag_mg ///
	wahlarenag_sg gesprhin pk_gesamtino pr_bild i_nupol ///
	pr_paper pr_andz tv_oeff tv_privat m_gesamti ///
	wkampfint intefficacy extefficacy zufr ///
	indiff entfremd entfremda  {

   bysort lfdn: egen mean_`var'=mean(`var') 
   gen d_`var'=`var'-mean_`var'
   drop mean_`var'
}
	
	
*-----------------------------
* Wave dummies
*-------------------------------

tab welle, gen(w)	
	

save "${path}\Reproducible Do-Files\Chapter 5\Data\longformat13.dta", replace	
